//
//  WCNMessageListCell.m
//  WCN
//
//  Created by wsj2015 on 16/3/17.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNMessageListCell.h"
#import "WCImageView +setImage.h"
#import "NSString+Utilities.h"
@implementation WCNMessageListCell

- (void)awakeFromNib {
    // Initialization code
    self.messageLabel.font = [UIFont systemFontOfSize:13];
    self.messageLabel.textColor = [UIColor orangeColor];
    self.replyLabel.font = [UIFont systemFontOfSize:13];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setModel:(WCNMessageContainer *)message{
    _model = message;
    
    [self.imageIcon setImageWithUrl:message.avatarFileId];
    
    self.nameLabel.text =[message.nickName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    self.messageLabel.text =message.messageContent;
    
    if (message.replyContent) {
        self.replyLabel.text =[NSString stringWithFormat:@"%@",message.replyContent];
    }else{
        
        self.replyLabel.text =[NSString stringWithFormat:@"暂未回复"];
    }
    
    if (message.replyTime ) {
        NSString *timeStr =[NSString stringWithFormat:@"%@",message.replyTime];
        self.timeLabel.text = [NSString timeToString:[timeStr longLongValue]];
    }else{
        self.replyLabel.text = [NSString stringWithFormat:@"等待回复"];
    }

    
    

}

+ (WCNMessageListCell *)CellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexpath
{
    static NSString *cellId =@"WCNMessageListCellId";
    WCNMessageListCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell =[[WCNMessageListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.backgroundColor =[UIColor whiteColor];
    return cell;
    
}
@end
